Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Using Sigslots Lite
Description: Shows how to set up signals and slots with ecl_sigslots_lite.Keywords: ecl sigslots lite
Tutorial Level: INTERMEDIATE
Next Tutorial: Debugging Sigslots Lite
Slots in the Background
Users of lite sigslots don't actually directly use Slot classes (unlike ecl_sigslots). Slots are still there, but they are stored behind the scenes, either in a global slots manager or member slots manager inherited by a class.
Storage Capacities
Signals and slots need to reserve memory before usage. This identifies how many connections each can handle. For global slots, you need to set a static variable before making any connections to slots of that type.
For member slots, your class needs to inherit from the MemberSlots interface and specify the capacity as a template parameter (default is 1).
For signals, simply specify the capacity template parameter (again default is 1) when instantiating the signal. This reflects the number of connections it can handle.
1 ecl::lite::Signal<const char*, 2> signal;
Connections
Connections are made via the connect functions, linking directly to the function pointers.